<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/books/css/list.css"/>
    <script type="text/javascript" src="/books/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/books/js/mobileSelect.js"></script>
	<link rel="stylesheet" type="text/css" href="/books/css/mobileSelect.css"/>
	<script type="text/javascript" src="/books/js/rem.js" ></script>
    <title>分公司现金日记账</title>
</head>
<body>
<div class="container">
	<div class="listtop">
		<div class="top_con1">
			<p class="year">{$info.year}年</p>
			<div>
				<span class="jiantou"></span>
				<div id="trigger4" class="trigger4" style="display: inline-block;">
					第{$info.week_text}周
				</div>
				 <input type="hidden" name="" id="week" value="" />								
			</div>
		</div>
		<div class="top_con2">
			<p>收入</p>
			<p>{$info.income_text}</p>
		</div>
		<div class="top_con3">
			<p>支出</p>
			<p>{$info.expenses_text}</p>
		</div>	
		<div class="top_con3">
			<p>结余</p>
			<p>{$info.balance_text}</p>
		</div>
	</div>
	<?php if(!empty($Books)){?>
			
	<ul class="list">
		<?php foreach($Books as $k=>$v){?>

		<li>
			<div class="title">
				<p><?php echo $v['time'],' ',$v['week'];?></p>
				<p>
					<span class="shou">收入</span> <?php echo $v['income']?:'0.00';?><br />
					<span class="chu">支出</span> <?php echo $v['expenditure']?:'0.00';?>
					
				</p>
			</div>
			<?php if(isset($v['Books_view'])){?>
				<div class="info">
				 <?php foreach($v['Books_view'] as $vv){?>
					<p> 
						{if $books_auth['edit'] && ($books_auth['department'] == $info['department'])}
							<a href="/index/books/edit/ids/{$vv.id}">
						{else}
							<a href="javascript:;">
						{/if}
						<?php echo !empty($vv['cost_id']) && $vv['pay_type'] == 2 ? TableField('Cost','name',$vv['cost_id']) : '备用金';?>
						<?php if($vv['pay_type'] == 1){ ?>
							<span><?php echo $vv['price'];?></span>
						<?php }else{ ?>
						   <span>-<?php echo $vv['price'];?></span>
						<?php }?>
							</a>
					</p>
			
				  <?php } ?>
				
				</div>
			<?php } ?>
		</li>
		<?php }?>
	</ul>
	 <?php }?>
	 	{if $books_auth['add'] && ($books_auth['department'] == $info['department'])}
			<a href="/index/books/add" class="addbutton">新增</a>
		{/if}
</div>
</body>
<script>
	var arr = [];
	var department = {$info['department']};
	var DefaultsDate = {$info['year']}-2018;
	var DefaultsDateW = 0;
	var years = {$info['year']};
	var week_text = {$info['week_text']};
  	$.ajax({
	  url: '/api/ajax/year_week',
	  type: 'post',
	  async: false,
	  data:{type:3,department:department,year:years,week_text:week_text},
	  success: function (year) {
	  	   arr = year.data.data;
	  	    DefaultsDate = year.data.year_more;
	  	   DefaultsDateW = year.data.week_more
	  	   console.log(year);
	  		/*$.each(year.data,function (index,value) {
	  			 arr[index] = value;
	  			$.get('https://oa.fc62.com/api/ajax/year?year='+value.value,function (week) {
						arr[index]['childs'] = week.data;
					});

		   });*/
	  }
	});
	var  mobileSelect4 = new MobileSelect({
	     trigger: '#trigger4',
	     title: '周次选择',
	     wheels: [{data:arr}],
	     position:[DefaultsDate,DefaultsDateW],
		 transitionEnd:function(indexArr, data){
		        
		 },
		 callback:function(indexArr, data){
		 	//console.log(data);
		 	$('.year').text(data[0].name);
		 	var strs = data[1].name.split(",");
		 	$('#trigger4').text(strs[0]);
		    $('#week').val(data[1].value);
		 	window.location.href = "/index/books/view/ids/"+data[1].value;
		 
		 }
	});
	
</script>
</html>
